package com.mfin.bom.adapter;

import java.util.Date;

import com.mfin.bom.interfaces.ICashbook;
import com.mfin.bom.interfaces.ICustomer;
import com.mfin.bom.interfaces.IFinance;
import com.mfin.bom.interfaces.IFinanceLoan;
import com.mfin.bom.interfaces.IPartner;
import com.mfin.bom.interfaces.IUser;
import com.mfin.bom.objects.Cashbook;
import com.mfin.enumeration.AccountCategory;
import com.mfin.enumeration.AccountHead;
import com.mfin.enumeration.TransactionMode;
import com.mfin.enumeration.TransactionType;
import com.mfin.vo.ObjectKey;

public class CashbookAdapter extends IIdentifiableAdapter implements ICashbook {
	private Cashbook wrappedCashbook = null;

	public CashbookAdapter(Cashbook cashbook, ObjectKey[] keys) {
		super();
		wrappedCashbook = cashbook;
		ObjectKey[] newkeys = new ObjectKey[2];
		newkeys[0] = keys[0];
		newkeys[1] = new ObjectKey(wrappedCashbook.getId());
		setKeys(newkeys);
	}

	public Cashbook getCashbook() {
		return wrappedCashbook;
	}

	@Override
	public Long getCashbookId() {
		return wrappedCashbook.getId();
	}

	@Override
	public void setCashbookId(Long id) {
		wrappedCashbook.setId(id);
	}

	@Override
	public IUser getUser() {
		return new UserAdapter(wrappedCashbook.getUser(), getKeys());
	}

	@Override
	public void setUser(IUser bomUser) {
		if (bomUser != null) {
			UserAdapter userAdapter = (UserAdapter) bomUser;
			wrappedCashbook.setUser(userAdapter.getUser());
		}
	}

	@Override
	public ICustomer getCustomer() {
		return new CustomerAdapter(wrappedCashbook.getCustomer(), getKeys());
	}

	@Override
	public void setCustomer(ICustomer bomCustomer) {
		if (bomCustomer != null) {
			CustomerAdapter customerAdapter = (CustomerAdapter) bomCustomer;
			wrappedCashbook.setCustomer(customerAdapter.getCustomer());
		}
	}

	@Override
	public IFinanceLoan getFinanceLoan() {
		return new FinanceLoanAdapter(wrappedCashbook.getFinanceLoan(),
				getKeys());
	}

	@Override
	public void setFinanceLoan(IFinanceLoan bomFinanceLoan) {
		if (bomFinanceLoan != null) {
			FinanceLoanAdapter financeLoanAdapter = (FinanceLoanAdapter) bomFinanceLoan;
			wrappedCashbook.setFinanceLoan(financeLoanAdapter.getFinanceLoan());
		}
	}

	@Override
	public IFinance getFinance() {
		return new FinanceAdapter(wrappedCashbook.getFinance());
	}

	@Override
	public void setFinance(IFinance bomFinanceInformation) {

		if (bomFinanceInformation != null) {
			FinanceAdapter financeInformationAdapter = (FinanceAdapter) bomFinanceInformation;
			wrappedCashbook.setFinance(financeInformationAdapter.getFinance());
		}
	}

	@Override
	public IPartner getPartner() {
		return new PartnerAdapter(wrappedCashbook.getPartner(), getKeys());
	}

	@Override
	public void setPartner(IPartner bomPartner) {
		if (bomPartner != null) {
			PartnerAdapter partnerAdapter = (PartnerAdapter) bomPartner;
			wrappedCashbook.setPartner(partnerAdapter.getPartner());
		}
	}

	@Override
	public Date getDate() {
		return wrappedCashbook.getDate();
	}

	@Override
	public void setDate(Date date) {
		wrappedCashbook.setDate(date);
	}

	@Override
	public AccountCategory getAccountCategory() {
		return wrappedCashbook.getAccountCategory();
	}

	@Override
	public void setAccountCategory(AccountCategory accountCategory) {
		wrappedCashbook.setAccountCategory(accountCategory);
	}

	@Override
	public AccountHead getAccountHead() {
		return wrappedCashbook.getAccountHead();
	}

	@Override
	public void setAccountHead(AccountHead accountHead) {
		wrappedCashbook.setAccountHead(accountHead);
	}

	@Override
	public Double getCredit() {
		return wrappedCashbook.getCredit();
	}

	@Override
	public void setCredit(Double credit) {
		wrappedCashbook.setCredit(credit);
	}

	@Override
	public Double getDebit() {
		return wrappedCashbook.getDebit();
	}

	@Override
	public void setDebit(Double debit) {
		wrappedCashbook.setDebit(debit);
	}

	@Override
	public String getPersonName() {
		return wrappedCashbook.getPersonName();
	}

	@Override
	public void setPersonName(String personName) {
		wrappedCashbook.setPersonName(personName);
	}

	@Override
	public String getBankName() {
		return wrappedCashbook.getBankName();
	}

	@Override
	public void setBankName(String bankName) {
		wrappedCashbook.setBankName(bankName);
	}

	@Override
	public TransactionMode getTransactionMode() {
		return wrappedCashbook.getTransactionMode();
	}

	@Override
	public void setTransactionMode(TransactionMode transactionMode) {
		wrappedCashbook.setTransactionMode(transactionMode);
	}

	@Override
	public String getChequeNumber() {
		return wrappedCashbook.getChequeNumber();
	}

	@Override
	public void setChequeNumber(String chequeNumber) {
		wrappedCashbook.setChequeNumber(chequeNumber);
	}

	@Override
	public TransactionType getTransactionType() {
		return wrappedCashbook.getTransactionType();
	}

	@Override
	public void setTransactionType(TransactionType transactionType) {
		wrappedCashbook.setTransactionType(transactionType);
	}

	@Override
	public String getPurpose() {
		return wrappedCashbook.getPurpose();
	}

	@Override
	public void setPurpose(String purpose) {
		wrappedCashbook.setPurpose(purpose);
	}

	@Override
	public String getTowards() {
		return wrappedCashbook.getTowards();
	}

	@Override
	public void setTowards(String towards) {
		wrappedCashbook.setTowards(towards);
	}

	@Override
	public String getRemarks() {
		return wrappedCashbook.getRemarks();
	}

	@Override
	public void setRemarks(String remarks) {
		wrappedCashbook.setRemarks(remarks);
	}
}
